import Vue from 'vue'
import Vuex from 'vuex'
import getters from './getters'
import user from './model/user'
import goods from './model/goods'
import address from './model/address'
import chat from './model/chat'
import setting from './model/setting'
import general from './model/general.js'
import bgm from './model/bgm.js'
import persistedstate from "vuex-persistedstate"

Vue.use(Vuex);
const store = new Vuex.Store({
	modules: {
		bgm,
		general,
		user,
		goods,
		address,
		chat,
		setting,
	},
	getters,
	plugins: [
		//持久化
		persistedstate({
			paths: ['general', 'user', 'goods', 'address', 'setting','chat','bgm'],
			storage: { // 存储方式定义  
				getItem: (key) => uni.getStorageSync(key), // 获取  
				setItem: (key, value) => uni.setStorageSync(key, value), // 存储  
				removeItem: (key) => uni.removeStorageSync(key) // 删除  
			},
		})
	]
});

export default store;